<?php
namespace app\index\model;

use think\Model;
use think\Db;

//聚合模型 
class Article extends Model
{
  public function getArticles()
    {
        $res=Db('article')
                ->alias('a')
                ->where('a.status', '1')
                ->join('user u','u.id=a.u_id')
                ->order('update_time desc')
                ->field('
                  a.id as a_id, 
                  title, 
                  content, 
                  u.username as author, 
                  a.update_time, 
                  a.create_time,
                  a.status
                ')
                ->select();
        return $res;
    }
}
